package cn.gov.pbc.tims.util;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;


public class Model implements java.io.Serializable {

	private List  filedList=new ArrayList<String>();
	private List  descriptionList=new ArrayList<String>();
	private String[] fields;
	private String fieldstr;
	private String[] descriptions;
	private Map<String, String> fieldsMap=new HashMap<>();

	
	public List getFiledList() {
		return filedList;
	}

	public void setFiledList(List filedList) {
		this.filedList = filedList;
	}

	public List getDescriptionList() {
		return descriptionList;
	}

	public void setDescriptionList(List descriptionList) {
		this.descriptionList = descriptionList;
	}

	public String[] getFields() {
		return fields;
	}

	public void setFields(String[] fields) {
		this.fields = fields;
	}

	public Map<String, String> getFieldsMap() {
		return fieldsMap;
	}
	public void setFieldsMap(Map<String, String> fieldsMap) {
		this.fieldsMap = fieldsMap;
	}
	public String[] getDescriptions() {
		return descriptions;
	}

	public void setDescriptions(String[] descriptions) {
		this.descriptions = descriptions;
	}

	public Model() {
		 
	}

 

	public String getFieldstr() {
		return fieldstr;
	}

	public void setFieldstr(String fieldstr) {
		this.fieldstr = fieldstr;
	}

	public Model(JsonNode js) {	
		fields=new String[js.size()];
		fieldstr="";
		descriptions=new String[js.size()];
		for(int i=0;i<js.size();i++)
		{
			String fname=js.get(i).get("fieldname").textValue();
			String fdescrip=js.get(i).get("description").textValue();
			filedList.add(fname);
			descriptionList.add(fdescrip);
			fieldsMap.put(fname,fdescrip);
			fields[i]=fname;
			fieldstr=fieldstr+fname+",";
			descriptions[i]=fdescrip;
		}
		fieldstr=fieldstr.substring(0, fieldstr.length()-1);
	}
		 
	}

	 